package com.example.testproject.activity

import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import com.example.testproject.R
import com.example.testproject.bean.BaseLiveDataBus
import com.example.testproject.bean.TestLiveData
import kotlinx.android.synthetic.main.activity_a_viscosity.*

/**
 *
 * @ClassName: AViscosityTestActivity
 * @Author: android 超级兵
 * @CreateDate: 11/15/21$ 7:33 PM$
 * TODO 测试粘性 liveData 并解决
 */
class AViscosityTestActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_a_viscosity)

        setBt.setOnClickListener {
            BaseLiveDataBus.with<String>("test", false).postValue("倚天屠龙记")
            // TestLiveData.textLiveData.postValue("九阳神功")
        }

        TestLiveData.textLiveData.observe(this) {
            headTv.text = "接收到数据:${it}"
        }

        BaseLiveDataBus.with<String>("test",false).observe(this) {
            headTv.text = "接收到数据:${it}"
        }
    }

    fun onJumpClick(view: View) {
        startActivity(Intent(this, BViscosityTestActivity::class.java))
    }

    override fun onResume() {
        super.onResume()
        BaseLiveDataBus.with<String>("test", false).postValue("onResume了")
    }
}